home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32-Tools / cdmpeg-110 / Display.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-27  |  14.8 KB  |  644 lines

  1. /*************
  2.  
  3.     Display.c
  4.     W.D.L 930330
  5.  
  6. **************/
  7.  
  8. /*
  9.  * COPYRIGHT: Unless otherwise noted, all files are Copyright (c) 1993-1999
  10.  * Amiga, Inc.  All rights reserved.
  11.  *
  12.  * DISCLAIMER: This software is provided "as is".  No representations or
  13.  * warranties are made with respect to the accuracy, reliability, performance,
  14.  * currentness, or operation of this software, and all use is at your own risk.
  15.  * Neither Amiga nor the authors assume any responsibility or liability
  16.  * whatsoever with respect to your use of this software.
  17.  */
  18.  
  19. // Tab size is 8!
  20.  
  21. #include <exec/types.h>
  22. #include <exec/memory.h>
  23. #include <intuition/intuition.h>
  24. #include <intuition/intuitionbase.h>
  25. #include <graphics/gfx.h>
  26. #include <graphics/gfxbase.h>
  27. #include <graphics/gfxmacros.h>
  28. #include <graphics/videocontrol.h>
  29.  
  30. #include <hardware/custom.h>
  31. #include <hardware/intbits.h>
  32.  
  33. #include <clib/exec_protos.h>
  34. #include <clib/intuition_protos.h>
  35. #include <clib/graphics_protos.h>
  36. #include <clib/macros.h>
  37.  
  38. #include <pragmas/exec_pragmas.h>
  39. #include <pragmas/intuition_pragmas.h>
  40. #include <pragmas/graphics_pragmas.h>
  41.  
  42. #include <string.h>    // for setmem()
  43. #include "stdio.h"
  44.  
  45.  
  46. #include "disp_def.h"
  47. #include "retcodes.h"
  48.  
  49. #include "debugsoff.h"
  50.  
  51. // Uncomment to get debug output turned on
  52. #define KPRINTF
  53. //#include "debugson.h"
  54.  
  55.  
  56.  
  57. IMPORT struct Library        * GfxBase;
  58. IMPORT struct Library        * IntuitionBase;
  59. IMPORT struct Library        * GameBase;
  60. IMPORT struct Custom          far custom;
  61.  
  62. IMPORT BOOL      DoScreen;
  63.  
  64.  
  65. VOID CloseDisplay( DISP_DEF * disp_def );
  66. //int kprintf(const char *, ...);
  67. int DoILBM( UBYTE * filename, DISP_DEF * disp_def );
  68. VOID    CopRoutine( VOID );    // In CopRoutine.a
  69.  
  70.  
  71. struct Interrupt CopInt;
  72. struct UCopList    * old_ucl,ucl;
  73. BOOL    CopIntAdded;
  74. BYTE    CopSigBit = -1;
  75. ULONG    CopSignal;
  76.  
  77. STATIC USHORT chip InvisiblePointer[]= {0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};
  78.  
  79. /*
  80.  * Data that gets passed into our copper interrupt routine.
  81.  */
  82. typedef    struct IntData {
  83.     struct Task    * Task;
  84.     ULONG      SigMask;
  85.  
  86. } INTDATA;
  87.  
  88. INTDATA CopIntData;
  89.  
  90. /*
  91.  * Set up the data that will get sent into the copper interrupt.
  92.  */
  93. SetUpIntData( INTDATA * intdata )
  94. {
  95.     if ( ( CopSigBit = AllocSignal(-1) ) != -1 ) {
  96.     CopSignal = intdata->SigMask = (1L << CopSigBit);
  97.     intdata->Task = FindTask( NULL );
  98.     return( TRUE );
  99.     }
  100.  
  101.     return( FALSE );
  102.  
  103. } // SetUpIntData()
  104.  
  105.  
  106. /*
  107.  * Add a copper interrupt that will signal us to call ChangeVPBitMap().
  108.  */
  109. VOID
  110. AddCopInt( DISP_DEF * disp_def, struct UCopList * ucl, struct Interrupt * copint, INTDATA * intdata )
  111. {
  112.     setmem( ucl, sizeof ( *ucl ), 0 );
  113.  
  114.     D(PRINTF("\n\n!!!!AddCopInt() ENTERED!!!!\n\n");)
  115.  
  116.     CINIT ( ucl, 50 );
  117.     CMOVE ( ucl, custom.intena, (INTF_SETCLR|INTF_COPER) );
  118.     CWAIT ( ucl, 0, 0 );
  119. //    CWAIT ( ucl, disp_def->Height, 0 );
  120.     CMOVE ( ucl, custom.intreq, (INTF_SETCLR|INTF_COPER) );
  121.     CEND ( ucl );
  122.  
  123.     old_ucl = disp_def->vp->UCopIns;
  124.     disp_def->vp->UCopIns = ucl;
  125.  
  126.     copint->is_Node.ln_Type = NT_INTERRUPT;
  127.     copint->is_Node.ln_Pri = 100;
  128.     copint->is_Node.ln_Name = "";
  129.     copint->is_Data = intdata;
  130.     copint->is_Code = CopRoutine;
  131.  
  132.     AddIntServer( INTB_COPER, copint );
  133.  
  134.     CopIntAdded = TRUE;
  135.  
  136.     if ( disp_def->Flags & DISP_SCREEN ) {
  137.     RethinkDisplay();
  138.     }
  139.  
  140. } // AddCopInt()
  141.  
  142.  
  143. ULONG
  144. GetModeID( DISP_DEF * disp_def )
  145. {
  146.     /* Check that the ModeID can handle doublebuffering.
  147.      * If not, then find the best ModeID that can.
  148.      */
  149.     struct DisplayInfo    disp;
  150.     ULONG        ModeID = disp_def->ModeID;
  151.  
  152.     D(PRINTF("GetModeID ENTERED with ModeID= 0x%lx\n",ModeID);)
  153.  
  154.     if ( GetDisplayInfoData(NULL, (UBYTE *)&disp, sizeof(struct DisplayInfo), DTAG_DISP, ModeID) ) {
  155.     D(PRINTF("GetModeID 1\n");)
  156.  
  157.     if ( ( disp_def->Flags & DISP_DBUF) && !(disp.PropertyFlags & DIPF_IS_DBUFFER) ) {
  158.  
  159.         D(PRINTF("GetModeID 2\n");)
  160.  
  161.         ModeID = BestModeID(BIDTAG_NominalWidth, disp_def->Width,
  162.         BIDTAG_NominalHeight, disp_def->Height,
  163.         BIDTAG_Depth, disp_def->Depth,
  164.         /* Keep the DIPF_ properties of the original
  165.          * ModeID, but ensure we have DBUFFER
  166.          * properties too.
  167.          */
  168.         BIDTAG_SourceID, ModeID,
  169.         BIDTAG_DIPFMustHave, DIPF_IS_DBUFFER,
  170.         TAG_END);
  171.     }
  172.     }
  173.  
  174.     D(PRINTF("GetModeID END with ModeID= 0x%lx\n",ModeID);)
  175.  
  176.     return( disp_def->ModeID = ModeID );
  177.  
  178. } // GetModeID()
  179.  
  180.  
  181. struct RGBEntry {
  182.     ULONG Red;
  183.     ULONG Green;
  184.     ULONG Blue;
  185.     };
  186.  
  187. struct ColorBunch {
  188.     UWORD cb_NumColors;
  189.     UWORD cb_FirstColor;
  190.     struct RGBEntry cb_Colors[4];
  191.     UWORD cb_EndMarker;  /* must be 0 */
  192. };
  193.  
  194. struct ColorBunch colors;
  195.  
  196. /*
  197.  * Open a screen and a window as defined by disp_def. Optionally
  198.  * load an ILBM file into background.
  199.  */
  200. ScrWinOpen( DISP_DEF * disp_def, UBYTE * ilbmfile )
  201. {
  202.     ULONG        flags,ErrorCode = 0;
  203.     int i;
  204.  
  205.     colors.cb_NumColors = 4;
  206.     colors.cb_FirstColor = 0;
  207.     colors.cb_EndMarker = 0;
  208.     for(i=0; i<4; i++)
  209.     {
  210.     colors.cb_Colors[i].Red   = 0x11111111;
  211.     colors.cb_Colors[i].Green = 0x11111111;
  212.     colors.cb_Colors[i].Blue  = 0x11111111;
  213.     }
  214.   
  215.     GetModeID( disp_def );
  216.  
  217.     D(PRINTF("ScrWinOpen() ENTERED with ModeID= 0x%lx, Width= %ld, Height= %ld, Flags= 0x%lx\n",
  218.     disp_def->ModeID,disp_def->Width,disp_def->Height,disp_def->Flags);)
  219.  
  220.     if ( disp_def->Flags & DISP_DBUF )
  221.     D(PRINTF("DISP_DBUF!!!!\n");)
  222.  
  223.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  224.     flags = BMF_CLEAR|BMF_DISPLAYABLE;
  225.  
  226.     if ( disp_def->Flags & DISP_INTERLEAVED )
  227.         flags |= BMF_INTERLEAVED;
  228.  
  229.     D(PRINTF("ScrWinOpen() Allocating bm[0]\n");)
  230.  
  231.     if (!(disp_def->bm[0] = (struct BitMap *)AllocBitMap( disp_def->Width, 
  232.      disp_def->Height, disp_def->Depth, flags, NULL )) ) {
  233.  
  234.         D(PRINTF("Could NOT AllocBitMap() 1\n");)
  235.         disp_def->bm[1] = NULL;
  236.         return( RC_NO_MEM );
  237.     }
  238.  
  239.     D(PRINTF("ScrWinOpen() GOT bm[0], BMA_WIDTH= %ld\n",GetBitMapAttr(disp_def->bm[0],BMA_WIDTH));)
  240.  
  241.     if ( disp_def->Flags & DISP_DBUF ) {
  242.         D(PRINTF("ScrWinOpen() Allocating bm[1]\n");)
  243.  
  244.         if (!(disp_def->bm[1] = (struct BitMap *)AllocBitMap( disp_def->Width, 
  245.         disp_def->Height, disp_def->Depth, flags, NULL )) ) {
  246.  
  247.         D(PRINTF("Could NOT AllocBitMap() 2\n");)
  248.  
  249.         FreeBitMap( disp_def->bm[0] );
  250.         disp_def->bm[0] = NULL;
  251.  
  252.         return( RC_NO_MEM );
  253.         }
  254.     }
  255.     }
  256.  
  257.     D(PRINTF("ScrWinOpen() disp_def->Top= %ld, Left= %ld, Height= %ld, Width= %ld\n",
  258.     disp_def->Top,disp_def->Left,disp_def->Height,disp_def->Width);)
  259.  
  260.     if ( disp_def->screen = OpenScreenTags(NULL,
  261.  
  262.     SA_Top,        disp_def->Top,
  263.     SA_Left,    disp_def->Left,
  264.     SA_Width,    disp_def->Width,
  265.     SA_Height,    disp_def->Height,
  266.     SA_Depth,    disp_def->Depth,
  267.     SA_BitMap,    disp_def->bm[0],
  268.     SA_DisplayID,    disp_def->ModeID,
  269.     SA_Interleaved,    (disp_def->Flags & DISP_INTERLEAVED) ? TRUE : FALSE,
  270.     SA_ShowTitle,    FALSE,
  271.     SA_Quiet,    TRUE,
  272.     SA_Behind,    TRUE,
  273.     SA_Colors32,    &colors,
  274.     SA_ErrorCode,    &ErrorCode,
  275.     TAG_DONE) )
  276.     {
  277.  
  278.     D(PRINTF("Got Screen Top= %ld, Left= %ld, Height= %ld, Width= %ld\n",
  279.         disp_def->screen->TopEdge,disp_def->screen->LeftEdge,
  280.         disp_def->screen->Height,disp_def->screen->Width);)
  281.  
  282.     if ( disp_def->window = OpenWindowTags( NULL,
  283.         WA_Width,        disp_def->screen->Width,
  284.         WA_Height,        disp_def->screen->Height,
  285.         WA_IDCMP,        NULL,    //IDCMP_MOUSEBUTTONS,
  286.         WA_Flags,        BACKDROP | BORDERLESS | RMBTRAP,
  287.         WA_Activate,    TRUE,
  288.         WA_CustomScreen,    disp_def->screen,
  289.         TAG_DONE) ) {
  290.  
  291.         D(PRINTF("ScrWinOpen() A\n");)
  292.  
  293.         if ( disp_def->Flags & DISP_NOPOINTER )
  294.         SetPointer( disp_def->window, InvisiblePointer, 1, 1, 0, 0 );
  295.  
  296.         D(PRINTF("ScrWinOpen() B\n");)
  297.  
  298.         disp_def->vp = &disp_def->screen->ViewPort;
  299.  
  300.         D(PRINTF("ScrWinOpen() C\n");)
  301.  
  302.         if ( !(disp_def->Flags & DISP_DBUF) || (disp_def->dbuf = AllocDBufInfo( disp_def->vp )) ) {
  303.  
  304.         D(PRINTF("ScrWinOpen() D\n");)
  305.  
  306.         if ( (disp_def->Flags & DISP_BACKGROUND) && ilbmfile && *ilbmfile ) {
  307.  
  308.             if ( DoILBM( ilbmfile, disp_def ) )
  309.             printf("Could not open '%ls'\n",ilbmfile);
  310.         }
  311.  
  312.         D(PRINTF("ScrWinOpen() E\n");)
  313.  
  314.         /*
  315.          * Add the copper interrupt.
  316.          */
  317.         if ( !(disp_def->Flags & DISP_COP_INT) || SetUpIntData( &CopIntData ) ) {
  318.             if ( disp_def->Flags & DISP_COP_INT ) 
  319.             AddCopInt( disp_def, &ucl, &CopInt, &CopIntData );
  320.  
  321.             D(PRINTF("ScrWinOpen() F\n");)
  322.  
  323.             ScreenPosition( disp_def->screen, SPOS_ABSOLUTE, disp_def->Left, disp_def->Top, 0, 0);
  324.  
  325.             D(PRINTF("ScrWinOpen() G\n");)
  326.  
  327.             ScreenToFront( disp_def->screen );
  328.  
  329.             D(PRINTF("ScrWinOpen() RC_OK\n");)
  330.  
  331.             return( RC_OK );
  332.         }
  333.         }
  334.         if ( disp_def->dbuf ) {
  335.         FreeDBufInfo( disp_def->dbuf );
  336.         }
  337.         CloseWindow( disp_def->window );
  338.         disp_def->window = NULL;
  339.     }
  340.  
  341.     CloseScreen( disp_def->screen );
  342.     disp_def->screen = NULL;
  343.  
  344.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  345.         FreeBitMap( disp_def->bm[0] );
  346.         FreeBitMap( disp_def->bm[1] );
  347.         disp_def->bm[0] = disp_def->bm[1] = NULL;
  348.     }
  349.     return( RC_NO_WIN );
  350.     }
  351.  
  352.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  353.     FreeBitMap( disp_def->bm[0] );
  354.     FreeBitMap( disp_def->bm[1] );
  355.     disp_def->bm[0] = disp_def->bm[1] = NULL;
  356.     }
  357.  
  358.     return( RC_NO_SC );
  359.  
  360. } // ScrWinOpen()
  361.  
  362.  
  363.  
  364. /*********
  365.  
  366.  View Stuff
  367.  
  368. **********/
  369.  
  370. struct View          View,* OldView;
  371. struct ViewPort       ViewPort;
  372. struct RasInfo          RasInfo;
  373. struct MonitorInfo      Monitor;
  374. struct ColorMap        * CMap;
  375. struct ViewPortExtra    * Vpx;
  376. struct ViewExtra    * Vx;
  377.  
  378.  
  379. /*
  380.  * Allocate a ViewExtra and attempt to obtain a MonitorInfo. Use
  381.  * the info from the MonitorInfo to set the ViewExtra->Monitor and
  382.  * set the view's Dx and DyOffset.
  383.  */
  384. struct ViewExtra *
  385. GetVX( struct View * view, ULONG ModeID )
  386. {
  387.     struct ViewExtra    * vx;
  388.  
  389.     if ( vx = GfxNew( VIEW_EXTRA_TYPE ) ) {
  390.     if ( GetDisplayInfoData( NULL, (UBYTE *)&Monitor, sizeof(Monitor), DTAG_MNTR, ModeID ) ) {
  391.         vx->Monitor = Monitor.Mspc;
  392.         view->DxOffset = Monitor.ViewPosition.x;
  393.         view->DyOffset = Monitor.ViewPosition.y;
  394.     }
  395.     }
  396.  
  397.     return( vx );
  398.  
  399. } // GetVX()
  400.  
  401.  
  402. /*
  403.  * Open a view as defined by disp_def. Optionally
  404.  * load an ILBM file into background.
  405.  */
  406. ViewOpen( DISP_DEF * disp_def, UBYTE * ilbmfile )
  407. {
  408.     ULONG         flags;
  409.     struct DimensionInfo diminfo;
  410.  
  411.     GetModeID( disp_def );
  412.  
  413.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  414.     flags = BMF_CLEAR|BMF_DISPLAYABLE;
  415.  
  416.     if ( disp_def->Flags & DISP_INTERLEAVED )
  417.         flags |= BMF_INTERLEAVED;
  418.  
  419.     if (!(disp_def->bm[0] = (struct BitMap *)AllocBitMap( disp_def->Width, 
  420.      disp_def->Height, disp_def->Depth, flags, NULL )) ) {
  421.  
  422.         D(PRINTF("Could NOT AllocBitMap() 1\n");)
  423.         return( RC_NO_MEM );
  424.     }
  425.  
  426.     if (!(disp_def->bm[1] = (struct BitMap *)AllocBitMap( disp_def->Width, 
  427.      disp_def->Height, disp_def->Depth, flags, disp_def->bm[0] )) ) {
  428.  
  429.         D(PRINTF("Could NOT AllocBitMap() 2\n");)
  430.         FreeBitMap( disp_def->bm[0] );
  431.         disp_def->bm[0] = NULL;
  432.         return( RC_NO_MEM );
  433.     }
  434.     }
  435.  
  436.     if ( CMap = GetColorMap( MAX ( (disp_def->Depth<<1), 256 ) ) ) {
  437.     InitView( &View );
  438.     InitVPort( &ViewPort );
  439.  
  440.     ViewPort.ColorMap = CMap;
  441.     ViewPort.DHeight = disp_def->Height;
  442.     ViewPort.DWidth = disp_def->Width;
  443.     ViewPort.Modes = disp_def->ModeID;
  444.     ViewPort.RasInfo = &RasInfo;
  445.     RasInfo.BitMap = disp_def->bm[0];
  446.     ViewPort.Next = View.ViewPort;
  447.     View.ViewPort = &ViewPort;
  448.  
  449.     if ( Vx = GetVX( &View, disp_def->ModeID ) ) {
  450.         GfxAssociate(&View,Vx);
  451.         View.Modes |= EXTEND_VSTRUCT;
  452.     }
  453.  
  454.     D(PRINTF("\nViewOpen() DxOffset= %ld, DyOffset= %ld, Left= %ld, Top= %ld\n",
  455.         View.DxOffset,View.DyOffset,disp_def->Left,disp_def->Top);)
  456.  
  457.     if ( 1 || !(disp_def->Flags & DISP_ALLOCBM ) ) {
  458.  
  459.         View.DxOffset += disp_def->Left;
  460.         View.DyOffset += disp_def->Top;
  461.     }
  462.  
  463.     D(PRINTF("ViewOpen() DxOffset= %ld, DyOffset= %ld, Left= %ld, Top= %ld\n",
  464.         View.DxOffset,View.DyOffset,disp_def->Left,disp_def->Top);)
  465.  
  466.     if ( Vpx = GfxNew(VIEWPORT_EXTRA_TYPE) ) {
  467.  
  468.         if( GetDisplayInfoData( NULL,(UBYTE *)&diminfo,
  469.         sizeof (diminfo), DTAG_DIMS, disp_def->ModeID) )
  470.             {
  471.  
  472. //        Vpx->DisplayClip = diminfo.MaxOScan;
  473.         Vpx->DisplayClip = diminfo.VideoOScan;
  474.  
  475.         }
  476.  
  477.         VideoControlTags(
  478.         CMap,VTAG_VIEWPORTEXTRA_SET,Vpx,
  479.         VTAG_ATTACH_CM_SET,&ViewPort,
  480.         VTAG_NORMAL_DISP_SET,FindDisplayInfo( disp_def->ModeID ),
  481.         VTAG_COERCE_DISP_SET,FindDisplayInfo( disp_def->ModeID ),
  482.         TAG_END
  483.         );
  484.  
  485.         disp_def->vp = &ViewPort;
  486.  
  487.         /*
  488.          * Add the copper interrupt.
  489.          */
  490.         if ( !(disp_def->Flags & DISP_COP_INT) || SetUpIntData( &CopIntData ) ) {
  491.         if ( disp_def->Flags & DISP_COP_INT ) 
  492.             AddCopInt( disp_def, &ucl, &CopInt, &CopIntData );
  493.  
  494.         MakeVPort( &View, &ViewPort );
  495.         MrgCop( &View );
  496.  
  497.         if ( !(disp_def->Flags & DISP_DBUF) || (disp_def->dbuf = AllocDBufInfo( disp_def->vp )) ) {
  498.             if ( (disp_def->Flags & DISP_BACKGROUND) && ilbmfile && *ilbmfile ) {
  499.  
  500.             if ( DoILBM( ilbmfile, disp_def ) )
  501.                 printf("Could not open '%ls'\n",ilbmfile);
  502.             }
  503.  
  504.             OldView = ((struct GfxBase *)GfxBase)->ActiView;
  505.             LoadView( &View );
  506.  
  507.             return( RC_OK );
  508.         }
  509.         }
  510.         CloseDisplay( disp_def );
  511.         return( RC_NO_MEM );
  512.     }
  513.  
  514.     FreeColorMap( CMap );
  515.     CMap = NULL;
  516.     }
  517.  
  518.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  519.     FreeBitMap( disp_def->bm[0] );
  520.     FreeBitMap( disp_def->bm[1] );
  521.     disp_def->bm[0] = disp_def->bm[1] = NULL;
  522.     }
  523.  
  524.     return( RC_NO_MEM );
  525.  
  526. } // ViewOpen()
  527.  
  528. /* 
  529.  * Open either a screen or a view.
  530.  */
  531. OpenDisplay( DISP_DEF * disp_def, UBYTE * ilbmfile )
  532. {
  533.     D(PRINTF("OpenDisplay() disp_def->Top= %ld\n",disp_def->Top);)
  534.  
  535.     if ( disp_def->Flags & DISP_SCREEN ) {
  536.     return( ScrWinOpen( disp_def, ilbmfile ) );
  537.     } else {
  538.     return( ViewOpen( disp_def, ilbmfile ) );
  539.     }
  540.  
  541. } // OpenDisplay()
  542.  
  543.  
  544. /* 
  545.  *  Close screen or view.
  546.  */
  547. VOID
  548. CloseDisplay( DISP_DEF * disp_def )
  549. {
  550.  
  551.     if ( CopIntAdded ) {
  552.     RemIntServer( INTB_COPER, &CopInt );
  553.     disp_def->vp->UCopIns = old_ucl;
  554.     RethinkDisplay();
  555.     FreeCopList( ucl.FirstCopList );
  556.     CopIntAdded = FALSE;
  557.     }
  558.  
  559.     if ( CopSigBit != -1 ) {
  560.     FreeSignal( CopSigBit );
  561.     CopSigBit = -1;
  562.     }
  563.  
  564.     if ( disp_def->dbuf )
  565.     FreeDBufInfo( disp_def->dbuf );
  566.  
  567.     /* 
  568.      * Close the screen and window.
  569.      */
  570.     if ( disp_def->Flags & DISP_SCREEN ) {
  571.     if ( disp_def->window ) {
  572.         CloseWindow( disp_def->window );
  573.         disp_def->window = NULL;
  574.     }
  575.  
  576.     if ( disp_def->screen ) {
  577.         CloseScreen( disp_def->screen );
  578.         disp_def->screen = NULL;
  579.     }
  580.     } else {
  581.     /* 
  582.      * We had a view not a screen.
  583.      */
  584.     if ( OldView ) {
  585.         LoadView( OldView );
  586.         OldView = NULL;
  587.     }
  588.  
  589.     if ( View.ViewPort )
  590.         FreeVPortCopLists( View.ViewPort );
  591.  
  592.     if ( Vpx ) {
  593.         GfxFree( Vpx );
  594.         Vpx = NULL;
  595.     }
  596.  
  597.     if ( Vx ) {
  598.         GfxFree( Vx );
  599.         Vx = NULL;
  600.     }
  601.  
  602.     if ( View.LOFCprList ) {
  603.         FreeCprList( View.LOFCprList );
  604.         View.LOFCprList = NULL;
  605.     }
  606.  
  607.     if ( CMap ) {
  608.         FreeColorMap( CMap );
  609.         CMap = NULL;
  610.     }
  611.     }
  612.  
  613.     /* 
  614.      * If we allocated these bitmaps with AllocBitMap(),
  615.      * free them with FreeBitMap().
  616.      */
  617.     if ( disp_def->Flags & DISP_ALLOCBM ) {
  618.     if ( disp_def->bm[0] )
  619.         FreeBitMap( disp_def->bm[0] );
  620.  
  621.     if ( disp_def->bm[1] )
  622.         FreeBitMap( disp_def->bm[1] );
  623.     }
  624.  
  625. } // CloseDisplay()
  626.  
  627.  
  628. VOID
  629. Display2Front( DISP_DEF * disp_def )
  630. {
  631.     if ( disp_def->Flags & DISP_SCREEN ) {
  632.     if ( disp_def->screen )
  633.         ScreenToFront( disp_def->screen );
  634.  
  635.     } else {
  636.     if ( View.LOFCprList ) {
  637.         OldView = ((struct GfxBase *)GfxBase)->ActiView;
  638.         LoadView( &View );
  639.     }
  640.     }
  641.  
  642. } // Display2Front()
  643.  
  644.